import java.io.*;
import java.net.*;

public class Practice9_2_Client {
	public static void main(String[] args) throws UnknownHostException, IOException{
		Socket socket = new Socket("127.0.0.1", 1680);
		PrintWriter out = new PrintWriter(socket.getOutputStream());
		BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
		String s;
		
		do {
			s = sin.readLine();
			out.println(s);
			out.flush();
			if(!s.equals("bye")) {
				System.out.println("@ Server response:" + in.readLine());
			}
		}while(!s.equals("bye"));
		
		out.close();
		in.close();
		socket.close();
		System.out.println("The connection is closed.");
	}
}
